<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>管理后台</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.4 -->
    <link href="/public/admin/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <!-- FontAwesome 4.3.0 -->
    <link href="/public/admin/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <!-- Ionicons 2.0.0 -->
    <link href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet" type="text/css" />
    <!-- Theme style -->
    <!-- AdminLTE Skins. Choose a skin from the css/skins
        folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/css/bootstrap-select.min.css">
    <!-- Bootstrap 3.3.4 -->
    <link href="/public/admin/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/public/admin/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="/public/admin/css/animate.css" rel="stylesheet">
    <link href="/public/admin/css/ratuo.css" rel="stylesheet">
    <link href="/public/admin/css/style.css?v=4.0.0" rel="stylesheet">
    <!-- jQuery 2.1.4 -->
    <script src="/public/admin/js/jQuery-2.1.4.min.js"></script>
    <script src="/public/admin/js/common.js"></script>
    <script src="/public/admin/js/myFormValidate.js"></script>
    <script src="/public/admin/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="/public/admin/js/plugins/layer/layer.min.js"></script><!-- 弹窗js 参考文档 http://layer.layui.com/-->
    <script src="/public/admin/js/myAjax.js"></script>
    <script src="/public/admin/js/jquery.validate.js"></script>
    <link href="/favicon.ico" type="image/x-icon" rel="shortcut icon" />

    <link href="/public/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <script src="/public/admin/js/plugins/iCheck/icheck.min.js"></script>
    <style>
        .table tbody tr th{vertical-align: middle; text-align: center;}
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑管理员</h5>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <form class="form-horizontal" method="post" id="adminHandle">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">管理组：</label>
                                <div class="col-sm-8">
                                    <select name="group_ids" class="form-control">
                                        <option value="" >请选择</option>
                                        {foreach name="group" item="v"}
                                            <option value="{$v['id']}"  {in name="v['id']" value="$group_data"} selected="selected" {/in}  >{$v['title']}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">管理员账号：</label>
                                <div class="col-sm-8">
                                    <input class="configInput form-control" type="text" name="user_name" value="{$data.user_name}"  {if !empty($data['user_name'])} disabled {/if} >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">管理员密码：</label>
                                <div class="col-sm-8">
                                    <input class="configInput form-control" type="password" name="password1" id="password1" value="{neq name="data.password" value=""}******{/neq}" onchange="$('input[name=password]').val($('input[name=password1]').val());" >
                                    <input class="configInput form-control" type="hidden" name="password" value="{$data.password}" >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">确定密码：</label>
                                <div class="col-sm-8">
                                    <input class="configInput form-control" type="password" name="pass1" value="{neq name="data.password" value=""}******{/neq}" >
                                </div>
                            </div>
                            <div class="form-group" style="display:none;">
                                <label class="col-sm-2 control-label">管理员状态：</label>
                                <div class="col-sm-8">
                                    <label class="checkbox-inline i-checks">
                                        <input type="radio" name="status" value="1" {if $data['status'] <> 0 OR empty($data) } checked="checked" {/if} >允许登录</label>
                                    <label class="checkbox-inline i-checks">
                                        <input type="radio" name="status" value="0" {if $data['status'] == 0 AND !empty($data) } checked="checked" {/if} >禁止登录</label>
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <input type="hidden" name="admin_id" value="{$data['admin_id']}">
                                    <input type="hidden" name="act" value="{$act}">
                                    <button class="btn btn-primary" type="submit">保存</button>
                                </div>
                            </div> 
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
$(document).ready(function(){
    $('.i-checks').iCheck({
        checkboxClass: 'icheckbox_square-green',
        radioClass: 'iradio_square-green'
    });


    $("#adminHandle").validate({
        onkeyup:false,
        rules: {
            user_name: { required: true , rangelength:[5,10]   },
            email:     { required: true, email: true },
            password1: { required: true, rangelength:[5,16]  },
            pass1:     { required: true, equalTo:"#password1"  }
        },
        messages: {
            user_name: {
                required: "账号必填",
                rangelength : '账号长度为5-10个字符'
            },
            email: {
                required: "*邮箱必填",
                email: "请输入正确的邮箱"
            },
            password1: {
                required: "密码必填",
                rangelength : '密码长度为5-16个字符'
            },
            pass1:{
                required: "密码必填",
                equalTo : '二次密码不相同'
            }
        },submitHandler:function(form) {
            ajax_submit_form('adminHandle','{:url("Admin/adminHandle")}');
        },errorPlacement: function (error, element) {
            layer.msg(error.text(), {icon: 2,time: 1000});
        }
    });
});

function adsubmit(){
    ajax_submit_form('adminHandle','{:url("Admin/adminHandle")}');
}
</script>
</body>
</html>